package com.banmoon.composite;

import cn.hutool.core.util.StrUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 学院
 */
public class College extends OrganizationComponent{

    private List<OrganizationComponent> orgList = new ArrayList<>();

    public College(String name, String desc) {
        super(name, desc);
    }

    @Override
    public void add(OrganizationComponent component) {
        System.out.println(StrUtil.format("{}添加了《{}》专业", getName(), component.getName()));
        orgList.add(component);
    }

    @Override
    public void remove(OrganizationComponent component) {
        System.out.println(StrUtil.format("{}移除了《{}》专业", getName(), component.getName()));
        boolean b = orgList.remove(component);
        if(!b)
            System.out.println(StrUtil.format("笑死，根本就没有《{}》这个专业", component.getName()));
    }

    @Override
    public void show() {
        System.out.println("===========" + getName() + "===========");
        orgList.forEach(OrganizationComponent::show);
    }
}
